package io;

import io.InputFrame;
import io.OutFrame;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Frame {
    public static void main(String[] args) {
        // 创建主窗口
        JFrame mainFrame = new JFrame("Main Window");
        mainFrame.setSize(400, 300);
        mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        mainFrame.setLayout(new BorderLayout());
        mainFrame.setLocationRelativeTo(null);

        // 创建输出框
//        JTextArea outputArea = new JTextArea();
//        outputArea.setEditable(false);
//        JScrollPane scrollPane = new JScrollPane(outputArea);
//        mainFrame.add(scrollPane, BorderLayout.CENTER);

        // 创建按钮面板
        JPanel buttonPanel = new JPanel();
        buttonPanel.setLayout(new FlowLayout());
        mainFrame.add(buttonPanel, BorderLayout.SOUTH);

        // 创建两个add按钮
        JButton addConditionButton = new JButton("Add Condition");
        JButton addConclusionButton = new JButton("Add Conclusion");
        buttonPanel.add(addConditionButton);
        buttonPanel.add(addConclusionButton);

        //创建proof按钮
        JButton proof = new JButton("Proof");
        buttonPanel.add(proof);

        // 为addCondition按钮添加监听器
        addConditionButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new InputFrame();
            }
        });

        // 为addConclusion按钮添加监听器
        addConclusionButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new InputFrame();
            }
        });

        // 为proof按钮添加监听器
        proof.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new OutFrame();
            }
        });



        //创建condition和conclusion窗口
        JPanel areaPanel =new JPanel();
        areaPanel.setLayout(new FlowLayout());
        mainFrame.add(areaPanel,BorderLayout.CENTER);

        JTextArea condition_a=new JTextArea();
        condition_a.setEditable(false);
        condition_a.append("Here are conditions:");
        areaPanel.add(condition_a);

        JTextArea conclusion_a=new JTextArea();
        conclusion_a.setEditable(false);
        conclusion_a.append("Here is the conclusion:");
        areaPanel.add(conclusion_a);

        mainFrame.setVisible(true);
    }
}
